package com.atguigu.tingshu.user.client;

import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.model.user.UserInfo;
import com.atguigu.tingshu.model.user.VipServiceConfig;
import com.atguigu.tingshu.user.client.impl.UserInfoDegradeFeignClient;
import com.atguigu.tingshu.vo.user.UserInfoVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.HashSet;

/**
 * <p>
 * 用户信息远程调用接口
 * </p>
 *
 * @author qy
 */
@FeignClient(value = "service-user",
        fallback = UserInfoDegradeFeignClient.class,
        contextId = "userInfoFeignClient"
)
public interface UserInfoFeignClient {

    /**
     * 根据用户id获取用户名称
     *
     * @param id 用户id
     * @return 用户名称
     */
    @GetMapping("client/user/userInfo/getUserName/{id}")
    String getUserNameById(@PathVariable("id") Long id);

    /**
     * 根据用户id获取用户信息
     *
     * @param id 用户id
     * @return 用户信息
     */
    @GetMapping("client/user/userInfo/getUserInfoById/{id}")
    UserInfo getUserInfoById(@PathVariable("id") Long id);


    /**
     * 判断用户是否购买了专辑
     *
     * @param albumId 专辑id
     * @return 是否购买专辑
     */
    @GetMapping("client/user/userPaid/isPaidAlbum/{albumId}")
    Boolean isPaidAlbum(@PathVariable("albumId") Long albumId);

    /**
     * 获取用户已购的音频id
     * @param albumId 专辑id
     * @param userId 用户id
     * @return 用户已购的音频id
     */
    @GetMapping("client/user/userPaid/getPaidTrackIds/{albumId}/{userId}")
    HashSet<Long> getPaidTrackIds(@PathVariable("albumId") Long albumId,
                                @PathVariable("userId") Long userId);

    /**
     * 根据vipId获取vip服务配置信息
     * @param vipId vipId
     * @return vip服务配置信息
     */
    @GetMapping("client/user/vipServiceConfig/getVipServiceConfig/{vipId}")
    VipServiceConfig getVipServiceConfig(@PathVariable("vipId") Long vipId);

    /**
     * 获取用户信息
     * @return userInfoVo用户信息
     */
    @GetMapping("client/user/userInfo/getUserInfoVo")
    Result<UserInfoVo> getUserInfoVo();
}